package com.A21.Object;
 
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;

public class Global {
	static TrnDetail _SelectedTrnDetail; 
    static MSTUser _LoggedInUser; 
	public static MSTUser getLoggedInUser()
	{
		return _LoggedInUser; 
	}
	public static void setLoggedInUser(MSTUser value)
	{
		_LoggedInUser = value;
	}
	
	public static TrnDetail getSelectedTrnDetail()
	{
		return _SelectedTrnDetail; 
	}
	public static void setSelectedTrnDetail(TrnDetail value)
	{
		_SelectedTrnDetail = value;
	}
	
	public static Date getDate(int year, int month, int day) {
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.YEAR, year);
        cal.set(Calendar.MONTH, month);
        cal.set(Calendar.DAY_OF_MONTH, day);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        return cal.getTime();
    }

	public static String SetLeadingZeros(int num, int digits) {
	    assert digits > 0 : "Invalid number of digits";

	    // create variable length array of zeros
	    char[] zeros = new char[digits];
	    Arrays.fill(zeros, '0');
	    // format number as String
	    DecimalFormat df = new DecimalFormat(String.valueOf(zeros)); 
	    return df.format(num);
	}
	
	public static String padRight(String s, int n) { 
		return String.format("%-10s", "bar");
	    
	}

	public static String padLeft(String s, int n) {
		 return String.format("%10s", "foo");
	}
	
	static ArrayList<MSTProduct> _MultiTierProduct; 
	
	public static ArrayList<MSTProduct> getMultiTierProduct()
	{
		return _MultiTierProduct; 
	}
	
	public static void setMultiTierProduct(ArrayList<MSTProduct> value)
	{
		_MultiTierProduct = value;
	}
	
	
	
	static MSTSettings _MSTSettings; 
	
	public static MSTSettings getMSTSettings()
	{
		return _MSTSettings; 
	}
	
	public static void setMSTSettings(MSTSettings value)
	{
		_MSTSettings = value;
	}
	
	
    static A21OrderHeader _OrderHeader; 
	
	public static A21OrderHeader getA21OrderHeader()
	{
		return _OrderHeader; 
	}
	
	public static void setA21OrderHeader(A21OrderHeader value)
	{
		_OrderHeader = value;
	}
	
	public static double RD(double v, int dc)
    {
        double temp = 0;
        int Vsign = 0;
        double remainder = 0; 
        temp = v; 
        if (temp == 0)
        {
            return 0;
        }
        else
        {
            if (temp < 0)
            {
                Vsign = -1;
            }
            else
            {
                Vsign = 1;
            } 
            temp = Math.abs(temp);
            temp = temp * (Math.pow(10, dc));
            remainder = temp - (long)(temp);
            temp = temp - remainder; 
            remainder = remainder + Double.valueOf(("0." + "0000000000".substring(0, dc) + "1")); 
            if (remainder >= 0.5) { temp += 1; }
            temp /= (Math.pow(10, dc)); 
            return temp * Vsign;
        }
    }
	 
}
